﻿Imports System.Data.SqlClient

Public Class ThiCongCt
    Private sSoTc As String
    Private sSoPhieu As String
    Private iTrangThai As Integer

    Public Property SoTc() As String
        Get
            Return sSoTc
        End Get
        Set(ByVal Value As String)
            sSoTc = Value
        End Set
    End Property

    Public Property SoPhieu() As String
        Get
            Return sSoPhieu
        End Get
        Set(ByVal Value As String)
            sSoPhieu = Value
        End Set
    End Property

    Public Property TrangThai() As Integer
        Get
            Return iTrangThai
        End Get
        Set(ByVal Value As Integer)
            iTrangThai = Value
        End Set
    End Property

End Class

Public Class ThiCongCtF

    Public Function UpdateTrangThai(ByVal sotc As String, ByVal sophieu As String, ByVal maloaivattu As String, ByVal slnt As Decimal) As Boolean
        Dim myProjCnn As New ProjectConnection
        Dim myCnn As New SqlConnection
        Dim myDat As New SqlDataAdapter
        Dim myDtb As New DataTable

        myCnn = myProjCnn.GetConnection
        myCnn.Open()

        Dim myCmd As New SqlCommand
        With myCmd
            .Connection = myCnn
            .CommandType = CommandType.StoredProcedure
            .CommandText = "ThiCongCt_UpdateNghiemThu"

            .Parameters.Add(New SqlClient.SqlParameter("@sotc", SqlDbType.Char))
            .Parameters("@sotc").Value = sotc

            .Parameters.Add(New SqlClient.SqlParameter("@sophieu", SqlDbType.Char))
            .Parameters("@sophieu").Value = sophieu

            .Parameters.Add(New SqlClient.SqlParameter("@maloaivattu", SqlDbType.Char))
            .Parameters("@maloaivattu").Value = maloaivattu

            .Parameters.Add(New SqlClient.SqlParameter("@slnt", SqlDbType.Decimal))
            .Parameters("@slnt").Value = slnt

            .Parameters.Add(New SqlClient.SqlParameter("@return", SqlDbType.Bit)).Direction = ParameterDirection.ReturnValue
            .ExecuteNonQuery()
        End With

        If myCmd.Parameters("@return").Value = 1 Then
            myCnn.Close()
            myCnn.Dispose()
            Return True
        Else
            myCnn.Close()
            myCnn.Dispose()
            Return False
        End If
    End Function


End Class

